//
//  BaseService.h
//  Baseproject
//
//  Created by gullmei on 15/9/11.
//  Copyright (c) 2015年 黄定坤. All rights reserved.
//

#import "GlobalConfig.h"

//正式服务器地址
//#define HOST @""

#if URL_CONDITION_FLAG == 0           //测试服务器地址
//服务器接口地址
#define HOST @"http://192.168.1.208/DMIS/api/"
#else                               //外网正式环境
#define HOST @"http://120.24.180.155/huhu"
#endif


//域名服务器地址
//#define HOST @""

#define Response_Success @""
#define  NET_ERROR   -88

#import <Foundation/Foundation.h>
#import "AFHTTPRequestOperationManager.h"
//#import <LJFramework/LJFramework.h>
#import "BaseModel.h"
#import "TypeConversion.h"

#import <CommonCrypto/CommonDigest.h>


#define AA_WEAK_MAKE(var) __weak __typeof(&*self)
@interface ResResult : NSObject
@property (nonatomic, strong) id resData;
@property (nonatomic, assign) NSInteger resCode;
@property (nonatomic, copy) NSString *errMessage;
@end
enum ResponseType{
    TYPE_OBJECT=0, //返回一个对象
    TYPE_ARRAY=1, //返回一个数组
    TYPE_OTHER ,  //专门正对那些不规范的后台解码而设
};

typedef void(^NetworkServiceRequestResult)(id object , int code );  //ui使用的回调
typedef void(^SaveResponseData)(id data, int code ); //保存数据的回调
typedef id(^DecodeData)(id responseObject );  //解码的回调
//供ui使用：代理delegate
@protocol responseDelegate <NSObject>
- (void)responseWithObject:(id)obj resultCode:(int)rcode error:(NSError *)error;
@end

@interface BaseService : NSObject
{
    NSString * _notificationName;
    NSString *  _hostUrl;  //服务器地址
    NSDictionary * _paramDict ;//请求参数
    Class   _modelclass;
    int    _reponseType;
}
@property(nonatomic, strong) NSString *notificationName; //回调通知
@property(nonatomic, strong)NSString * hostUrl; //服务器地址
@property(nonatomic, strong)NSDictionary * paramDict;

@property(nonatomic,assign)int    reponseType;
@property(nonatomic,strong)NSString * sign;
@property(nonatomic, weak) id<responseDelegate> delegate; //回调代理

@property (nonatomic, copy) NetworkServiceRequestResult httpRequestResultBlock;
@property (nonatomic, copy) SaveResponseData saveToGlobalData;
@property (nonatomic, copy) DecodeData decodeData;
@property (nonatomic,assign) Class modelclass ;
@property(nonatomic,copy)NSString*keyStr;
/**
 *	@brief	初始化单例
 *
 *	@return	对象类
 */
+ (instancetype)getObject;

/**
 *	@brief	以post方式发送网络请求
 *
 *	@param 	urlString 	拼接好的URL
 *	@param 	param 	所要发送给服务器的参数
 *	@param 	aSuccess 	当返回数据时可以做定制化处理
 *
 */
- (void)postRequestWithUrl:(NSString *)urlString parameter:(id)param success:(id (^)(id responseObject, NSError *error))aSuccess;
/**
 *	@brief	接受回报处理函数
 */
-(void)OnRecvData:(id)data rcode:(int)code;
/**
 *	@brief	启动函数
 */
-(void)startPostRequest;
+ (NSString *)md5HexDigest:(NSString*)input;

@end
